const app = getApp()
const connector = require('../../utils/connector.js');
Page({
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
    advertising:[
      // { src: '../../images/taber/index1.png' },
      // { src: '../../images/taber/shopping1.png' },
      // { src: '../../images/taber/admin_circle1.png' },
      //"https://data.xuanheng99.com/sampleGraph/159127215083600a93.jpg"//背景
    //"https://data.xuanheng99.com/sampleGraph/15912722124396b990.png"//缴费
    //"https://data.xuanheng99.com/sampleGraph/1591272247231d9b51.png"//vip
    //"https://data.xuanheng99.com/sampleGraph/159135304069143d03.png"//缴费
    //"https://data.xuanheng99.com/sampleGraph/159135301058065fa2.png"//vip
    ],
  },
  imageBook(e){
    console.log(e.currentTarget.dataset.ids)
    wx.navigateTo({
      url: './advertising/advertising?ids=' + e.currentTarget.dataset.ids,
    })
  },
  //科目预约
  practice(e){
    // wx.navigateTo({
    //   url: '/pages/serve/serve',
    // })
    wx.navigateTo({
      url: '/pages/serve/tiku/tkce',
    })
    // wx.navigateTo({
    //   url: '/pages/vip/qiniu/qiniu',
    // })
  },
  //驾考vip
  vip(e) {
    wx.navigateTo({
      url: '/pages/vip/newVip/newVip',
      // url: '/pages/shopping/subject/subject',
    })
  },
  //
  order(e) {
    wx.navigateTo({
      url: '/pages/shopping/order/order',
      // url: '/pages/shopping/subject/subject',
    })
  },
  onLoad: function (options) {
    // console.log(options)
    // let oopp = "school_8&pid_4147"
    // console.log(oopp)
    
  },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    advertList(this)
    
  },
  /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
    var that = this
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新

  },
  onShareAppMessage: function () {
    var that = this
    // let val = app.searchWord
    // console.log(val)
    return {
      title: "欢迎进入题库",
      // path: '/pages/card/card?id=share_' + wx.getStorageSync('USERID'),
      path: '/pages/first/first?goTo=1&school=' +  wx.getStorageSync('userInfo').school_id + '&pid=' + app.globalData.myId,
      success: function (res) {
      },
      fail: function (res) {
        // 分享失败
      }
    }
 
  }
})
//获取广告  
function advertList(that) {
  connector.getFunc(connector.connector().advertList, "", "get", app.tokens, function (res) {
    // console.log(res)
    if (res.statusCode == 200) {
      // console.log(res.data)
      that.setData({
        advertising:res.data
      })
      // WxParse.wxParse('article', 'html', res.data.content, that);
      // console.log(res.data.content)
      // that.setData({
      //   shopping:res.data.content,
      // })

    } else {
      connector.showToasts(res.statusCode + ":" + res.errMsg)

    }
  }, function (res) {
    connector.showToasts("内部错误")
  })
}